#include "dish.h"
#include "ui_dish.h"



dish::dish(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::dish)
{
    ui->setupUi(this);

}

QString dish::getRandomDish(const QStringList &dishes)
{
    // 确保字符串列表不为空
    if (dishes.isEmpty()) {
        qDebug() << "字符串列表为空，无法生成随机字符串";
        return QString(); // 返回空字符串
    }
        // 获取全局的随机数生成器实例
        auto generator = QRandomGenerator::global();
        // 生成一个介于 0 到字符串列表大小之间的随机索引
        int index = generator->bounded(dishes.size());
        // 从字符串列表中获取一个随机字符串
        return dishes[index];
}

dish::~dish()
{
    delete ui;
}

void dish::on_zc_btn_clicked()
{

    ui->ZC_label->setText(getRandomDish(maindish));
}


void dish::on_fc_btn_clicked()
{
    ui->FC_label->setText(getRandomDish(Gdish));
}


void dish::on_pc1_btn_clicked()
{
    ui->PC1_label->setText(getRandomDish(Hdish1));
}


void dish::on_pc2_btn_clicked()
{
    ui->PC2_label->setText(getRandomDish(Hdish2));

}


void dish::on_pc3_btn_clicked()
{
    ui->PC3_label->setText(getRandomDish(Hdish3));
}


void dish::on_jc_btn_clicked()
{

    ui->JC_label->setText(getRandomDish(C));
}


void dish::on_load_btn_clicked()
{
    ui->ZC_label->setText(getRandomDish(maindish));
    ui->FC_label->setText(getRandomDish(Gdish));
    ui->PC1_label->setText(getRandomDish(Hdish1));
    ui->PC2_label->setText(getRandomDish(Hdish2));
    ui->PC3_label->setText(getRandomDish(Hdish3));
    ui->JC_label->setText(getRandomDish(C));

}
